﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SF.WebClient.Controllers
{
    public class ValidateboxController : BasicController
    {
        public void ViewValidateboxSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.css");
        }

        #region rules 规则

        public ViewResult RulesDemo()
        {
            return View();
        }

        public PartialViewResult RulesSource()
        {
            return PartialView();
        }

        public void ViewRulesSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.rules.js");
        }

        public PartialViewResult RulesExplain()
        {
            return PartialView();
        }

        #endregion

        #region ext 多种属性和方法

        public ViewResult ExtDemo()
        {
            return View();
        }

        public PartialViewResult ExtSource()
        {
            return PartialView();
        }

        public void ViewExtSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.js");
        }

        public PartialViewResult ExtExplain()
        {
            return PartialView();
        }

        #endregion

        #region setRequired 设置是否允许为空

        public ViewResult SetRequiredDemo()
        {
            return View();
        }

        public PartialViewResult SetRequiredSource()
        {
            return PartialView();
        }

        public void ViewSetRequiredSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.setRequired.js");
        }

        public PartialViewResult SetRequiredExplain()
        {
            return PartialView();
        }

        #endregion

        #region remoteValid 远程验证规则

        public ViewResult RemoteValidDemo()
        {
            return View();
        }

        public PartialViewResult RemoteValidSource()
        {
            return PartialView();
        }

        public void ViewRemoteValidSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.rules.remote.js");
        }

        public PartialViewResult RemoteValidExplain()
        {
            return PartialView();
        }

        #endregion

        #region updateRules 更新验证规则

        public ViewResult UpdateRulesDemo()
        {
            return View();
        }

        public PartialViewResult UpdateRulesSource()
        {
            return PartialView();
        }

        public void ViewUpdateRulesSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.updateRules.js");
        }

        public PartialViewResult UpdateRulesExplain()
        {
            return PartialView();
        }

        #endregion

        private Dictionary<string, string> userNameCache = new Dictionary<string, string>();

        public bool CheckUserNameExist(string value, string key)
        {
            userNameCache.Add("1", "admin");
            userNameCache.Add("2", "seven");
            userNameCache.Add("3", "easyui");
            userNameCache.Add("4", "extlib");

            return userNameCache.Any(a => a.Value == value && a.Key != key);
        }
    }
}